<?php
/**
 * Created by PhpStorm.
 * User: edmmss
 * Date: 2018/12/20
 * Time: 17:27
 */

namespace app\modules\mediator;


use app\modules\mediator\subsystem\Client;
use app\modules\mediator\subsystem\Database;
use app\modules\mediator\subsystem\Server;

class Mediator implements MediatorInterface
{
    /**
     * @var Server
     */
    private $_server;

    /**
     * @var Database
     */
    private $_database;

    /**
     * @var Client
     */
    private $_client;

    /**
     * Mediator constructor.
     * @param Database $database
     * @param Client $client
     * @param Server $server
     */
    public function __construct(Database $database, Client $client, Server $server)
    {
        $this->_database = $database;
        $this->_client = $client;
        $this->_server = $server;

        $this->_database->setMediator($this);
        $this->_client->setMediator($this);
        $this->_server->setMediator($this);
    }

    /**
     * className
     *
     * @date   2018/12/20
     * @author edmmss
     * @param $content
     * @return mixed
     */
    public function sendResponse($content)
    {
        // TODO: Implement sendResponse() method.
        $this->_client->output($content);
    }

    /**
     * className
     *
     * @date   2018/12/20
     * @author edmmss
     * @return mixed
     */
    public function makeRequest()
    {
        // TODO: Implement makeRequest() method.
        $this->_server->process();
    }

    /**
     * className
     *
     * @date   2018/12/20
     * @author edmmss
     * @return mixed
     */
    public function queryDb()
    {
        // TODO: Implement queryDb() method.
        $this->_database->getData();
    }
}